	<?php $this->load->view('common/head')?>
	
	<!-- Begin of Sidebar -->
	<?php $this->load->view('common/sidebar')?>
	
	<?php /*********************************/ ?>
	
	
	<style>
		th {background:#284860;color:#fff}
		
		td.middle {vertical-align:middle;text-align:center}
	</style>
		<!-- Modal Box Content -->
	<div id="dialog" title="About" style="display: none;">
		<p class='p1'></p>
		<p class='p2'></p>
	</div> 
	
	    <!-- Begin of #main -->
    <div id="main" role="main">
    	
    	<!-- Begin of titlebar/breadcrumbs -->
		<div id="title-bar">
			<ul id="breadcrumbs">
				<li><a href="dashboard.html" title="Home"><span id="bc-home"></span></a></li>
				<li><a href="<?php echo site_url('/admin/admin/')?>" title="Admin Spot">Admin Spot</a></li>
				<li><a href="<?php echo site_url('/admin/role/')?>" title="Roles">Roles</a></li>
				<li class="no-hover">Main</li>
			</ul>
		</div> <!--! end of #title-bar -->
		
		<div class="shadow-bottom shadow-titlebar"></div>
		
		<!-- Begin of #main-content -->
		<div id="main-content">
			<div class="container_12">
			
			
			<div class="grid_12">
				<div class="block-border">
				<div class="block-header"><h1>Roles & Groups</h1></div>
				<div class="block-content">
						<div class="block-actions">
							<ul class="actions-right">
								<li><button class="submit" onClick="load_form()">Add New Role</button></li>
							</ul>
						</div>
					</div>
					</div>
			</div>
			
			<!--  -->

			
			<!-- Example Block with Border -->
			<div class="grid_5">
				<div class="block-border">
					<div class="block-header">
						<h1>Roles List</h1><span></span>
					</div>
					<div class="block-content">
						<p>
							<table id="role_table" width=100% border=1 cellpadding=3 cellspacing=3>
							<tr>
								<th> Role Name </td>
								<th> Enable Flags? </td>
								<th> Role Description </th>
								<th> Add Flag(s) to Role </th>
								<th> Edit Role </th>
								<th> Delete Role </th>
							</tr>
							<?php foreach($list as $role):?>
							<tr id="row<?php echo $role->role_id?>">
								<td class="middle"><a href="javascript:;" title="<?php echo $role->role_name?>" onClick="load_role(<?php echo $role->role_id?>,this.title)"><?php echo $role->role_name?></a></td>
								<td class="middle"><input id="checkbox_<?php echo $role->role_id?>" type="checkbox" <?php if($role->enable_flags) echo "checked='checked'"?> title="<?php echo $role->role_name?>" onClick="enable_flags(<?php echo $role->role_id?>)" /></td>
								<td><?php echo $role->description?></td>
								<td class="middle"><a href="javascript:;" onClick="flag(<?php echo $role->role_id?>)"><img src="<?php echo $this->config->item('images')?>/icons/packs/fugue/16x16/flag.png" alt="Add Flag to <?php echo $role->role_name?>" title="Add Flag to <?php echo $role->role_name?>" /></a></td>
								<td class="middle"><a onClick="load_form(<?php echo $role->role_id?>)" href="javascript:;"><img src="<?php echo $this->config->item('images')?>/icons/packs/fugue/16x16/pencil.png" alt="Edit <?php echo $role->role_name?>" title="Edit <?php echo $role->role_name?>" /></a></td>
								<td class="middle"><a href="<?php echo $role->role_id?>"><img src="<?php echo $this->config->item('images')?>/icons/packs/fugue/16x16/slash.png" alt="Delete <?php echo $role->role_name?>" title="Delete <?php echo $role->role_name?>" /></a></td>
							</tr>
							<?php endforeach?>
							</table>
						</p>
					</div>
				</div>
			</div>
			
			<!--  -->
			<div class="grid_7">
				<div class="block-border">
					<div class="block-header">
						<h1 id="for_title">Options & Settings for (Roles/Groups)</h1><span></span>
					</div>
					<div class="block-content ">
						<div class="load_option"></div>
					</div>

				</div>
			</div>
		
		
			<div class="clear height-fix"></div>

		</div></div> <!--! end of #main-content -->
  </div> <!--! end of #main -->

	
	<script type="text/javascript">
	
		/*** enable flags ***/
		function enable_flags(id)
		{
			x = 1;
			if($('#checkbox_'+id).attr('checked')!='checked')
				x = 0;
				
			$.get("<?php echo site_url('admin/role/enable_flags/')?>/"+id+"/"+x,
				function(data){
					if(data)
						$.jGrowl( $('#checkbox_'+id).attr('title')+'<br>Saved..', { theme: 'saved',position:'center'  });
			}, 'json');
			$('#row'+id).effect("highlight", {}, 3000);
		}
		/*** END enable flags ***/
			
		/*** add flags form ***/
		function flag(com)
		{
			$('p.p1, p.p2').html(com).hide();
			$("#dialog").dialog({title:"Loading Form...", autoOpen:true});
			$('p.p1').load('<?php echo site_url('flag/role/')?>/'+com, function() {
				  $('p.p1').fadeIn('slow');
				  $("#dialog").dialog({title:"Add Flags to Role/Group"});
			});
		}
		/*** End add flags form ***/
		
		var TITLE = '';
		/** load_role **/
		function load_role(id, title)
		{
			TITLE = title;
			$('.load_option').slideUp('slow');
			$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
			if(id!=null){
				//load form
				$('.load_option').load('<?php echo site_url('admin/role/load_role')?>/'+id, function() {
				  $('#for_title').html('<sup>(Role: '+title+')</sup> Edit Permissions Role/Group');
				  $('.load_option').slideDown('slow');
				});
			}
		}
		/** END load_role **/
	
		/** load_form **/
		function load_form(id)
		{
			$('.load_option').slideUp('slow');
			$('#for_title').html('<center><img src="<?php echo $this->config->item('images')?>/loading2.gif" alt="Loading..." title="Loading..." /> Loading... </center>');
			if(id==null)
			{
				//load empty form
				$('.load_option').load('<?php echo site_url('admin/role/form')?>', function() {
				  $('#for_title').html('Add New Role/Group');
				  $('.load_option').slideDown('slow');
				});
			}
			else{
				//load form
				$('.load_option').load('<?php echo site_url('admin/role/form')?>/'+id, function() {
				  $('#for_title').html('Edit Role/Group');
				  $('.load_option').slideDown('slow');
				});
			}
		}
		/** END load_form **/
	
	$().ready(function(){
					$('#dialog').dialog({ 
					minWidth: 450,
					position: "top",
					autoOpen: false,
					modal: true, 
					show: "slide", 
					hide: "slide",
					title: "Loading..." 
			});
	});
	
	</script>
	
	
	
	
	
	<?php /*********************************/ ?>
	<!-- Begin of footer -->
	<?php $this->load->view('common/footer')?>
